package java_lab1;

public class Stack 
{
    
    class stackItem 
    {
	    stackItem bottom;
	    char downElement;
	    stackItem(char makeD) 
	    {
	    	downElement = makeD;
	    }
    }

    stackItem top;
    int size;

    Stack() 
    {
	    top = null;
	    size = 0;
	}
   
	public int getLength() 
	{
	    return size;
	}

	public void push(char element) 
	{
	    stackItem newTop = new stackItem(element);
	    newTop.bottom = top;
	    this.top = newTop;
	    size++;
	}

	public char pop() 
	{
	    char elementToPop = top.downElement;
	    stackItem old = top;
	    this.top = this.top.bottom;
	    old.bottom = null;
	    size--;
	    //System.out.print(elementToPop);
	    return elementToPop;
	}    
}

